-
-
Notifications
You must be signed in to change notification settings - Fork 233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emit 'unsubsribe' event when client has clean=true on disconnect #145 #171
Conversation
lib/handlers/unsubscribe.js
Outdated
@@ -68,7 +68,7 @@ function completeUnsubscribe (err) { | |||
return client.emit('error', err) | |||
} | |||
|
|||
if (!packet.close && packet.unsubscriptions.length > 0) { | |||
if (client.clean === true && packet.unsubscriptions.length > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the check for packet.close
must stay. See https://github.com/mcollina/aedes/blob/275bda32461ea8053c8610b8a3e5b6f0f838f1b6/lib/client.js#L214.
Basically if packet.close === true && client.clean === false
we should not emit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mcollina , thank you for a clarification, please see the new commit
@@ -123,7 +123,7 @@ test('emit unsubscribe event', function (t) { | |||
t.plan(6) | |||
|
|||
var broker = aedes() | |||
var s = connect(setup(broker), { clientId: 'abcde' }) | |||
var s = connect(setup(broker), { clean: true, clientId: 'abcde' }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add another test that fails if the event is emitted when clean is false and the connection ends abruptly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
forget about it, it's already added.
LGTM |
@mcollina , i've implemented #145, please review if it's ok to merge.